# Definition for a binary tree node.
class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right


class Solution:
    def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
        treenode = []
        stack = []
        CurNode = root
        while CurNode or stack:
            if CurNode:
                stack.append(CurNode)
                CurNode = CurNode.left
            else:
                CurNode = stack.pop()
                treenode.append(CurNode.val)
                CurNode = CurNode.right
        return treenode

if __name__ == '__main__':
    s = Solution()
    print(s.inorderTraversal(TreeNode(1, None, TreeNode(2, TreeNode(3), None))))